"""
 -*- coding: utf-8-*-
 @File: page_create_owner.py
 @Author: chen
 @time: 2024/01/10/ 19:43
"""
from ui_test.page_po_test.page_business.page_base import BasePage


class CreateOwnerPage(BasePage):
    def input_first_name(self, first_name):
        text_first_name = (self.by.NAME, "firstName")
        self.logger.info(f"输入姓氏：{first_name}")
        self.do_input(text_first_name, first_name)
        return self

    def input_last_name(self, last_name):
        text_last_name = (self.by.NAME, "lastName")
        self.logger.info(f"输入名字：{last_name}")
        self.do_input(text_last_name, last_name)
        return self

    def input_address(self, address):
        text_last_name = (self.by.NAME, "address")
        self.logger.info(f"输入地址：{address}")
        self.do_input(text_last_name, address)
        return self

    def input_city(self, city):
        text_last_name = (self.by.NAME, "city")
        self.logger.info(f"输入地址：{city}")
        self.do_input(text_last_name, city)
        return self

    def input_telephone(self, telephone):
        text_last_name = (self.by.NAME, "telephone")
        self.logger.info(f"输入地址：{telephone}")
        self.do_input(text_last_name, telephone)
        return self

    def click_add_owner_btn(self):
        btn_add_owner = (self.by.XPATH, '//*[text()="Add Owner"]')
        self.logger.info(f"点击Add Owner按钮")
        self.do_click(btn_add_owner)
        return self

    def back_to_owner_mgt_page(self):
        btn_back = (self.by.XPATH, '//*[text()="Back"]')
        self.logger.info(f"点击返回按钮")
        self.do_click(btn_back)
        from ui_test.page_po_test.page_business.page_home import HomePage
        self.logger.info("回到首页")
        return HomePage(self.driver)

    def create_to_owner_mgt_page(self, first_name, last_name, address, city, telephone):
        self.input_first_name(first_name). \
            input_last_name(last_name). \
            input_address(address). \
            input_city(city). \
            input_telephone(telephone).\
            click_add_owner_btn()
        from ui_test.page_po_test.page_business.page_owner_mgt import OwnerMgtPage
        self.logger.info("进入宠物主人列表页面")
        return OwnerMgtPage(self.driver)
